from django.db import models
from myutils.base_model import BaseModel


class AdvertisingCate(BaseModel):
    """
    广告分类
    """
    name = models.CharField(max_length=32, verbose_name='广告分类名')

    class Meta:
        db_table = 'advertising'
        verbose_name = '广告分类'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Contents(BaseModel):
    title = models.CharField(max_length=32, verbose_name='标题')
    content = models.TextField(null=True, blank=True, verbose_name='内容')
    img = models.ImageField(upload_to='adver_img', null=True, blank=True, verbose_name='图片')
    is_show = models.BooleanField(default=1, verbose_name='是否展示')
    cate = models.ForeignKey(AdvertisingCate, on_delete=models.CASCADE, verbose_name='所属分类')
    serial_number = models.CharField(max_length=30, verbose_name='序号')

    class Meta:
        db_table = 'content'
        verbose_name = '广告内容'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title






